﻿using IntelligentAgriculture.Contracts.Interface.Iridgepletype;
using IntelligentAgriculture.WebAPI.Application.Command.RidgepCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.RidgepCommandHandler
{
    public class RidgepDeleteCommandHandler : IRequestHandler<RidgepDeleteCommand, Results<int>>
    {
        private readonly IridegpoleService _ridegpoleService;
        public RidgepDeleteCommandHandler(IridegpoleService ridegpoleService)
        {
            _ridegpoleService = ridegpoleService;
        }
        /// <summary>
        /// 删除栋舍命令的请求
        /// </summary>
        /// <param name="request">要处理的耳标删除命令</param>
        /// <param name="cancellationToken">取消操作的取消标记</param>
        /// <returns>一个表示操作结果的异步任务，返回删除操作的结果</returns>
 
        public async Task<Results<int>> Handle(RidgepDeleteCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _ridegpoleService.Delete(request.Id);
                return Results<int>.DataResult(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
